<template>
	<view class="content">
		<!-- 头部 -->
		<view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">
				{{ item.text }}
			</view>			
		</view>
		<!-- 显示区域 -->
		<view class="">
			<view class="nav_item mar-top-20" >
				<view class="flex job-item" v-if="tabCurrentIndex == status" v-for="(item,index) in jobList" :key="index" @click="toDetail(item.id)">
					<view class="flex-1">
						<view class="fc-33 fs-32 font-bold">{{item.jobName}}</view>
						<view class="fc-99 fs-26 pad-top-20">广东省 佛山市 · {{item.requestExperience}} · {{item.requestEducation}}·{{item.salaryRang}}</view>
					</view>					
					<view v-if="item.status == 0" class="fs-32 font-bold fc-f1a">待审核</view>
					<view v-if="item.status == 2" class="fs-32 font-bold fc-df5">审核失败</view>
					<view v-if="item.status == 3" class="fs-32 font-bold fc-f1a">关闭</view>					
				</view>		
				<!-- <view class="flex job-item" v-if="tabCurrentIndex == 2">
					22222		
				</view> -->
			</view>
			
		</view>
		<view class="btn-row top-line">
			<button type="primary" class="btn-save" @tap="addNew()">发布新职位</button>
		</view>
		
	</view>
</template>

<script>

export default {
	data() {
		return {
			enterpriseIds:'',//公司id
			tabCurrentIndex: 0,
			status:0,
			page: 1, //分页	
			navList: [
				{				
					state: -1,//state为切换内容
					text: '全部',
				},
				{
					state: 0,
					text: '招聘中',
				},
				{
					state: 1,
					text: '待开放',
				},
				{
					state: 2,
					text: '审核失败',
				},	
			],
			jobList:[],//职位列表
			
		};
	},

	onLoad(options) {
		// 页面显示是默认选中第一个
		this.tabCurrentIndex = 0;
	},
	onShow(){
		this.getEnterprise_jobList()
	},
	mounted() {
		let that = this	
		this.getEnterprise_jobList()
		
	},
	methods: {
		//顶部tab点击
		tabClick(index) {
			this.tabCurrentIndex = index;
			this.status = index
			this.page = 1;
			this.getEnterprise_jobList()
		},
		//获取职位列表
		async getEnterprise_jobList(){
			var that = this
			let param = {
				pageNum: 1,
				pageSize: 10,
				imgType:1,
				wxuserId:uni.getStorageSync('wxuser_id'),
				status:this.status,
			}
			let data = await this.$apis.getEnterprise_jobList(param);
			if(data){				
				this.jobList = data.rows
				
			}
		},
		/* 发布职位 */
		addNew() {
			this.$mRouter.push({
				route: this.$mRoutesConfig.positionEdit
			});
		},
		//职位详情
		toDetail(id) {
			this.$mRouter.push({
				route: this.$mRoutesConfig.positionEdit,
				query: {
					jobid: id
				}
			});
		},
	}
};
</script>

<style lang="scss">
page,
.content {
	background: #fff;
	height: 100%;
}

.swiper-box {
	height: calc(100% - 40px);
}
.list-scroll-content {
	height: 100%;
}

.navbar {
	display: flex;
	height: 40px;
	padding: 0 5px;
	background: #fff;
	box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
	position: relative;
	z-index: 10;
	.nav-item {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
		font-size: 15px;
		color: #333;
		position: relative;
		&.current {
			color: #84C0F4;
			&:after {
				content: '';
				position: absolute;
				left: 50%;
				bottom: 0;
				transform: translateX(-50%);
				width: 44px;
				height: 0;
				border-bottom: 2px solid #84C0F4;
			}
		}
	}
}
.job-item{
	padding: 26rpx 32rpx;
}
.btn-row {
	position: fixed;
	z-index: 999;
	bottom: 0upx;
	padding: 20upx 0;
	background-color: #ffffff;
	width: 100%;
	box-sizing: border-box;
	padding-bottom: constant(safe-area-inset-bottom);
	padding-bottom: env(safe-area-inset-bottom);
	box-sizing: content-box;
	.btn-save {
		background-color: #84C0F4;
		height: 80upx;
		line-height: 80upx;
		font-size: $font-size-34;
		width: 90%;
		display: block;
		margin: 0 auto;
	}
}
</style>
